<?php

namespace app\admin\controller;

use think\Controller;

class User extends Controller
{
    protected $user;
    public function __construct()
    {
        parent::__construct();
        $this->user=new \app\common\model\User();
    }

    public function index(){
        $userList=$this->user->where('user_id','<>',1)->select();
        $this->assign('userList',$userList);
        return $this->fetch();
    }
    public function changeState(){
        $userId=input('param.id');
        $user=$this->user->where('user_id',$userId)->find();
        if($user['user_state']){
            $this->user->where('user_id',$userId)->update(['user_state'=>0]);
        }else{
            $this->user->where('user_id',$userId)->update(['user_state'=>1]);
        }
        return $this->success('操作成功');

    }
    public function search(){
        $phone=input('param.phone');
        $user=$this->user->where('user_name',$phone)->find();
        if($user){
            $this->assign('user',$user);
        }
        return $this->fetch();
    }
}
